<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="108px">
      <el-form-item label="姓名" prop="userId">
        <el-select v-model="queryParams.userId" clearable filterable placeholder="请选择用户名" >
          <el-option
            v-for="item in namelist"
            :key="item.value"
            :label="item.label"
            :value="item.value"
            size="small">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="studentList">
      <el-table-column label="姓名" align="center" prop="userName" />
      <el-table-column label="入园出勤" align="center" prop="className" />
      <el-table-column label="健康检查" align="center" prop="deviceName" />
      <el-table-column label="饮水" align="center" prop="deviceType"/>
      <el-table-column label="睡眠" align="center" prop="status"/>
      <el-table-column label="身高" align="center" prop="schoolCode" />
      <el-table-column label="体重" align="center" prop="schoolCode" />
      <el-table-column label="运动" align="center" prop="schoolCode" />
      <el-table-column label="兴趣" align="center" prop="schoolCode" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
          >修改</el-button>
<!--          <el-button-->
<!--            size="mini"-->
<!--            type="text"-->
<!--            icon="el-icon-delete"-->
<!--            @click="handleDelete(scope.row)"-->
<!--            v-hasPermi="['base:student:remove']"-->
<!--          >删除</el-button>-->
          <!--          <el-button-->
          <!--            size="mini"-->
          <!--            type="text"-->
          <!--            icon="el-icon-view"-->
          <!--            @click="handleDelete(scope.row)"-->
          <!--            v-hasPermi="['base:student:remove']"-->
          <!--          >查看</el-button>-->
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改学生对话框 -->
    <el-dialog  :close-on-click-modal="false" :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-tabs type="card" >
          <el-form-item label="姓名" prop="userId">
            <el-select v-model="form.userId" clearable filterable placeholder="请选择用户名" disabled>
              <el-option
                v-for="item in namelist"
                :key="item.value"
                :label="item.label"
                :value="item.value"
                size="small">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="入园出勤" prop="schoolCode">
            <el-input
              v-model="form.schoolCode"
              size="small"
            />
          </el-form-item>
          <el-form-item label="健康检查" prop="schoolCode">
            <el-input
              v-model="form.schoolCode"
              size="small"
            />
          </el-form-item>
          <el-form-item label="饮水" prop="schoolCode">
            <el-input
              v-model="form.schoolCode"
              size="small"
            />
          </el-form-item>
          <el-form-item label="睡眠" prop="schoolCode">
            <el-input
              v-model="form.schoolCode"
              size="small"
            />
          </el-form-item>
          <el-form-item label="身高" prop="schoolCode">
            <el-input
              v-model="form.schoolCode"
              size="small"
            />
          </el-form-item>
          <el-form-item label="体重" prop="schoolCode">
            <el-input
              v-model="form.schoolCode"
              size="small"
            />
          </el-form-item>
          <el-form-item label="运动" prop="schoolCode">
            <el-input
              v-model="form.schoolCode"
              size="small"
            />
          </el-form-item>
          <el-form-item label="兴趣" prop="schoolCode">
            <el-input
              v-model="form.schoolCode"
              size="small"
            />
          </el-form-item>
          <el-form-item label="家长寄语" prop="schoolCode">
            <el-input
              v-model="form.schoolCode"
              size="small"
              type="textarea"
              disabled
            />
          </el-form-item>
          <el-form-item label="老师寄语" prop="schoolCode">
            <el-input
              v-model="form.schoolCode"
              size="small"
              type="textarea"
            />
          </el-form-item>

        </el-tabs>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

  </div>
</template>

<script>


export default {
  name: "cdmonth",
  data() {
    return {
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      namelist:[],
      // 总条数
      total: 0,
      // 遮罩层
      loading: true,
      studentList:[],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      form:{},
    };
  },
  created() {
    this.getList()
  },
  methods: {
    getList(){
      this.loading=false
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      console.log(row)
      this.reset();
      const id = row.id || this.ids
      this.form = Object.assign({}, this.form, row)
      this.open = true;
      this.title = "修改设备管理";
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
